<?php

class HProject extends CModel  {
	/**
	 * @var integer $id
	 * @soap
	 */
	public $id ;

	/**
	 * @var string $activity
	 * @soap
	 */
	public $activity ;

	/**
	 * @var string $description
	 * @soap
	 */
	public $description ;

	/**
	 * @var string $route_mnemonic
	 * @soap
	 */
	public $route_mnemonic ;

	/**
	 * @var integer $owner_id
	 * @soap
	 */
	public $owner_id ;

	/**
	 * @var HMeetings[] $meetings
	 * @soap
	 */
	public $meetings ;

	/**
	 * @var HOwner $owner
	 * @soap
	 */
	public $owner ;

	/**
	 * @var HProjectTopic[] $topics
	 * @soap
	 */
	public $topics ;

	public function attributeNames() {
		return array ('id','activity','description','route_mnemonic','owner_id','meetings','owner','topics');
	}
	
	public function setAttributes($values,$safeOnly=true)
	{
		if (array_key_exists('owner', $values)){
			if (!($values['owner'] instanceof HOwner) && ($values['owner'] instanceof Owner)) {
				$owner = new HUser();
				$owner->attributes = $values['owner']->attributes;
				$values['owner'] = $owner;
			} else if (is_array($values['owner'])) {
				$owner = new HUser();
				$owner->attributes = $values['owner'];
				$values['owner'] = $owner;
			}
		}
		if (array_key_exists('meetings', $values)){
			if (is_array($values['meetings'])) {
				$meetings = array();
				foreach ($values['meetings'] as $m) {
					if (!($m instanceof HOwner) && ($m instanceof Meetings)) {
						$meeting = new HMeetings();
						$meeting->attributes = $m->attributes;
						$meetings[] = $meeting;
					} else if (is_array($m)) {
						$meeting = new HMeetings();
						$meeting->attributes = $m;
						$meetings[] = $meeting;
					} else if ($m instanceof HMeetings) {
						$meetings[] = $m;
					}
				}
				$values['meetings'] = $meetings;
			}
		}
		if (array_key_exists('topics', $values)){
			if (is_array($values['topics'])) {
				$topics = array();
				foreach ($values['topics'] as $m) {
					if (!($m instanceof HProjectTopic) && ($m instanceof ProjectTopic)) {
						$topic = new HProjectTopic();
						$topic->attributes = $m->attributes;
						$topics[] = $topic;
					} else if (is_array($m)) {
						$topic = new HProjectTopic();
						$topic->attributes = $m;
						$topics[] = $topic;
					} else if ($m instanceof HMeetings) {
						$topics[] = $m;
					}
				}
				$values['topics'] = $topics;
			}
		}
				
		parent::setAttributes($values, $safeOnly);
	}

	public function __toString() {
		return "HProject [" .
			"route_mnemonic=" . $this->route_mnemonic .
			", owner_id=" . $this->owner_id .
			", meetings=" . $this->meetings .
			", owner=" . $this->owner .
			", route=" . $this->route .
			", topics=" . $this->topics .
			", id=" . $this->id .
			", activity=" . $this->activity .
			", description=" . $this->description .
			"]";
	}
}
